#ifndef RECENTFILES_H
#define RECENTFILES_H

#include <QObject>
#include <QStringList>
class RecentFilesIO;

class RecentFiles : public QObject
{
Q_OBJECT

public:
    static const int MaxNumFiles;

public:
    explicit RecentFiles(QObject *parent = 0);
    ~RecentFiles();
    RecentFiles(const RecentFiles& recentFiles);
    RecentFiles& operator=(const RecentFiles& rhs);
    void add(const QString& filename);
    void clear();
    int count() const;

    /**
      * Checks whether the recent files exist on the filesystem. If a file
      * is no longer present on disk, then it is removed.
      */
    void existentialCheck();
    QString filename(int i) const;
    const QStringList& list() const;
    int maxNumRecentFiles() const;

    void read();

    void remove(const QString& filename);

    /**
      * Use the Strategy pattern to set how the recent files will be read and written.
      */
    void setIO(RecentFilesIO *recentFilesIO);
    void setList(const QStringList& recentFileNames);

    /**
      * Moves the entry to the front of the recent files list. This has no
      * effect if the entry is already at the front of the list.
      * @param filename The name of the entry to move.
      */
    void setMostRecent(const QString& filename);
    void write();

private:

    /** More recent files are added to the front, oldest ones at the end. */
    QStringList m_recentFileNames;

    /** The object used for reading and writing the recent file list. */
    RecentFilesIO *m_recentFilesIO;
};

#endif // RECENTFILES_H
